<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title></title>
    <!-- Bootstrap Styles-->
    <link href="__BACK__/css/bootstrap.css" rel="stylesheet"/>
    <!-- FontAwesome Styles-->
    <link href="__BACK__/css/font-awesome.css" rel="stylesheet"/>
    <!-- Custom Styles-->
    <link href="__BACK__/css/custom-styles.css" rel="stylesheet"/>
    <!-- Google Fonts-->
    <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'/>
</head>
<body>
<div id="wrapper">
    {include file="public/top"}
    <!--/. NAV TOP  -->
    {include file="public/left"}
    <!--/. NAV TOP  -->
    <!-- /. NAV SIDE  -->
    <div id="page-wrapper">
        <div id="page-inner">
            <div class="row">
                <div class="col-md-12">
                    <h1 class="page-header">
                        编辑用户
                    </h1>
                </div>
            </div>
            <!-- /. ROW  -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">

                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <!-- /.col-lg-6 (nested) -->
                                <div class="col-lg-4">
                                    <form role="form" method="post" >
                                        <input type="hidden" name="id" value="" />

                                        <div class="form-group ">
                                            <label class="control-label"  >头像</label>
                                            <!--<input type="text" class="form-control" name="portrait" value="">-->
                                            <div class="big-photo">
                                                <div id="preview">
                                                    <img id="imghead" border="0" src="{$userinfo['portrait']?$userinfo['portrait']:'__BACK__/img/upload-bj1.png'}" width="150" height="150" onclick="$('#previewImg').click();">
                                                </div>
                                                <input type="file" onchange="previewImage(this)" style="display: none;" id="previewImg">
                                                <!--<input id="uploaderInput" class="uploader__input" style="display: none;" type="file" accept="" multiple="">-->
                                                <input type="hidden" name="portrait" id="thumb" value="{$userinfo['portrait']}">
                                            </div>
                                        </div>

                                        <div class="form-group ">
                                            <label class="control-label" >id</label>
                                            <input type="text" class="form-control" id="" name="id" value="{$userinfo['id']}" disabled>
                                        </div>
                                        <div class="form-group ">
                                                <label class="control-label"  >用户名</label>
                                            <input type="text" class="form-control" name="mobile" value="{$userinfo['mobile']}" disabled>
                                        </div>

                                        <div class="form-group ">
                                            <label class="control-label"  >密码</label>
                                            <input type="text" class="form-control" name="pwd" value="">
                                        </div>

                                        <div class="form-group ">
                                            <label class="control-label"  >昵称</label>
                                            <input type="text" class="form-control" name="nickname" value="{$userinfo['nickname']}">
                                        </div>

                                        <div class="form-group ">
                                            <label class="control-label"  >余额</label>
                                            <input type="text" class="form-control" name="balance" value="{$userinfo['balance']}">
                                        </div>

                                        <div class="form-group ">
                                            <label class="control-label"  >当前挑战支付的挑战金</label>
                                            <input type="text" class="form-control" name="money" value="{$project['money']}">
                                        </div>

                                        <div class="form-group ">
                                            <label class="control-label"  >累计奖金</label>
                                            <input type="text" class="form-control" name="add_bonus" value="{$userinfo['add_bonus']}">
                                        </div>

                                        <button type="submit" class="btn btn-default">保存</button>
                                        <button type="reset" class="btn btn-default">重置</button>
                                    </form>


                                </div>
                                <!-- /.col-lg-6 (nested) -->
                            </div>
                            <!-- /.row (nested) -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <footer>
            </footer>
        </div>
        <!-- /. PAGE INNER  -->
    </div>
    <!-- /. PAGE WRAPPER  -->
</div>
<script>
    //图片上传预览    IE是用了滤镜。
    function previewImage(file)
    {
        var MAXWIDTH  = 150;
        var MAXHEIGHT = 150;
        var div = document.getElementById('preview');
        if (file.files && file.files[0])
        {
            div.innerHTML ='<img id=imghead onclick=$("#previewImg").click()>';
            var img = document.getElementById('imghead');
            img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
//                 img.style.marginLeft = rect.left+'px';
                img.style.marginTop = rect.top+'px';
            }
            var reader = new FileReader();
            reader.onload = function(evt){
                img.src = evt.target.result;
                $('#thumb').val(evt.target.result);
            }
            reader.readAsDataURL(file.files[0]);
            // $('#preview').append("<button>取消</button>");
        }
        else //兼容IE
        {
            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
            file.select();
            var src = document.selection.createRange().text;
            div.innerHTML = '<img id=imghead>';
            var img = document.getElementById('imghead');
            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
        }
    }
    function clacImgZoomParam( maxWidth, maxHeight, width, height ){
        var param = {top:0, left:0, width:width, height:height};
        if( width>maxWidth || height>maxHeight ){
            rateWidth = width / maxWidth;
            rateHeight = height / maxHeight;

            if( rateWidth > rateHeight ){
                param.width =  maxWidth;
                param.height = Math.round(height / rateWidth);
            }else{
                param.width = Math.round(width / rateHeight);
                param.height = maxHeight;
            }
        }
        param.left = Math.round((maxWidth - param.width) / 2);
        param.top = Math.round((maxHeight - param.height) / 2);
        return param;
    }
</script>
<!-- /. WRAPPER  -->
<!-- JS Scripts-->
<!-- jQuery Js -->
<script src="__BACK__/js/jquery-1.10.2.js"></script>
<!-- Bootstrap Js -->
<script src="__BACK__/js/bootstrap.min.js"></script>
<!-- Metis Menu Js -->
<script src="__BACK__/js/jquery.metisMenu.js"></script>
<!-- Custom Js -->
<script src="__BACK__/js/custom-scripts.js"></script>


</body>
</html>
